'use strict';

const Controller = require('egg').Controller;

class DataService extends Controller {
  async cha(name) {
    return await this.app.mysql.query('select * from data where name = ?',[name])
  }
  async add(name,title) {
    return await this.app.mysql.query("insert into data (name,title,time) values (?,?,?)",[name,title,new Date()])
  }
  async sc(id) {
   return  await this.app.mysql.delete('data', {
        id: id,
      });
  }
  async g(id,name,title) {
 // return await this.app.mysql.query('updata data set name = ? , title = ? , time = ? where id = ?',[name,title,new Date().getTime(),id])
    return await this.app.mysql.update('data', {
        id,name,title,time:new Date()
    });
    }
    async c(nr)
    {
        return await this.app.mysql.query(`select * from data where title like '%${nr}%'`)
    }
}

module.exports = DataService;